﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vds2465Telegrams
{
    public class UserData_26_BlockStateAll : UserData_Address
    {
        #region private member variables

        private readonly byte[] _inputBytes;
		private readonly byte[] _outputBytes;
		private readonly byte[] _disruptionBytes;

        #endregion private member variables

        #region constructor

        public UserData_26_BlockStateAll(byte device, byte address, byte addressAddOn, byte[] inputBytes, byte[] outputBytes, byte[] disruptionBytes)
            : base(UserData.UserData26BlockStateAll, device, address, addressAddOn)
        {
			if (inputBytes != null)
			{
				_inputBytes = new byte[inputBytes.Length];
				for (int index = 0; index < inputBytes.Length; index++)
				{
					_inputBytes[index] = inputBytes[index];
				}
			}
			else
			{
				_inputBytes = new byte[0];
			}

			if (outputBytes != null)
			{
				_outputBytes = new byte[outputBytes.Length];
				for (int index = 0; index < outputBytes.Length; index++)
				{
					_outputBytes[index] = outputBytes[index];
				}
			}
			else
			{
				_outputBytes = new byte[0];
			}

			if (disruptionBytes != null)
			{
				_disruptionBytes = new byte[disruptionBytes.Length];
				for (int index = 0; index < disruptionBytes.Length; index++)
				{
					_disruptionBytes[index] = disruptionBytes[index];
				}
			}
			else
			{
				_disruptionBytes = new byte[0];
			}
        }

		#endregion constructor

        #region getters

        public byte[] GetCopyOfInputBytes()
        {
			byte[] retInputBytes = new byte[_inputBytes.Length];
			for (int index = 0; index < _inputBytes.Length; index++)
			{
				retInputBytes[index] = _inputBytes[index];
			}

			return retInputBytes;
        }

		public byte[] GetCopyOfOutputBytes()
		{
			byte[] retOutputBytes = new byte[_outputBytes.Length];
			for (int index = 0; index < _outputBytes.Length; index++)
			{
				retOutputBytes[index] = _outputBytes[index];
			}

			return retOutputBytes;
		}

		public byte[] GetCopyOfDisruptionBytes()
		{
			byte[] retDisruptionBytes = new byte[_disruptionBytes.Length];
			for (int index = 0; index < _disruptionBytes.Length; index++)
			{
				retDisruptionBytes[index] = _disruptionBytes[index];
			}

			return retDisruptionBytes;
		}

        #endregion getters

        #region ToString, Equals, GetHashCode

        public override int GetHashCode()
        {
            int hashCode = base.GetHashCode();

			hashCode ^= UserDataCommon.GetHashCode_ByteArray(_inputBytes);
			hashCode ^= UserDataCommon.GetHashCode_ByteArray(_outputBytes);
			hashCode ^= UserDataCommon.GetHashCode_ByteArray(_disruptionBytes);
			
			return hashCode;
        }

        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("(");
            stringBuilder.Append(ToStringProperties());
            stringBuilder.Append(")");

            return stringBuilder.ToString();
        }

        internal override string ToStringProperties()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append(base.ToStringProperties());

            stringBuilder.Append(", ");
			stringBuilder.Append(UserDataCommon.HexByteArrayToString("InputBytes", _inputBytes));

			stringBuilder.Append(", ");
			stringBuilder.Append(UserDataCommon.HexByteArrayToString("OutputBytes", _outputBytes));

			stringBuilder.Append(", ");
			stringBuilder.Append(UserDataCommon.HexByteArrayToString("DisruptionBytes", _disruptionBytes));
            
            return stringBuilder.ToString();
        }

        public override bool Equals(object obj)
        {
            Type objType = obj.GetType();
            if (this.GetType() == objType)
            {
                UserData_26_BlockStateAll userData2Compare = obj as UserData_26_BlockStateAll;
                return EqualsProperties(userData2Compare);
            }

            return false;
        }

        internal bool EqualsProperties(UserData_26_BlockStateAll userData2Compare)
        {
            if (base.EqualsProperties(userData2Compare))
            {
                if (UserDataCommon.Equals2ByteArrays(_inputBytes, userData2Compare.GetCopyOfInputBytes()))
				{
					if (UserDataCommon.Equals2ByteArrays(_outputBytes, userData2Compare.GetCopyOfOutputBytes()))
					{
						return UserDataCommon.Equals2ByteArrays(_disruptionBytes, userData2Compare.GetCopyOfDisruptionBytes());
					}

					return false;
				}

				return false;
            }

            return false;
        }

        #endregion ToString, Equals, GetHashCode
    }
}
